<!DOCTYPE html>
<html lang="en">
<head>
  <title>教师信息管理系统</title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="../css/bootstrap.min.css" />
  <link rel="stylesheet" href="../css/bootstrap-responsive.min.css" />
  <link rel="stylesheet" href="../css/colorpicker.css" />
  <link rel="stylesheet" href="../css/datepicker.css" />
  <link rel="stylesheet" href="../css/uniform.css" />
  <link rel="stylesheet" href="../css/select2.css" />
  <link rel="stylesheet" href="../css/matrix-style2.css" />
  <link rel="stylesheet" href="../css/matrix-media.css" />
  <link rel="stylesheet" href="../css/bootstrap-wysihtml5.css" />
  <link href="../font-awesome/css/font-awesome.css" rel="stylesheet" />
  <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
</head>
<body>

<div id="content">
  <div id="content-header">
    <h1>教师岗位异动情况</h1>
  </div>

  <div class="container-fluid">
    <div>
      <form class="form-horizontal" style="display: inline-block; ">
        <div class="control-group" style="display: inline-block;">
          <span class="control-label">教师姓名：</span>
          <div class="controls">
            <input id="name" type="text"  />
          </div>
        </div>
        <div class="control-group" style="display: inline-block; ">
          <span class="control-label">异动类型：</span>
          <div class="controls">
            <select id="moveType2" >
              <option value=""></option>
              <option value="调出">调出</option>
              <option value="退休">退休</option>
              <option value="出国进修">出国进修</option>
              <option value="病休产假">病休产假</option>
            </select>
          </div>
        </div>
        <div class="control-group" style="display: inline-block; ">
          <span class="control-label">开始时间：</span>
          <div class="controls">
            <input id="startTime" type="date"  />-至-
            <input id="endTime" type="date"  />
          </div>
        </div>
      </form>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <button id="su" class="btn btn-warning" style="display: inline-block; ">搜索</button>
    </div>
    <hr>
    <button id="adde" class="btn btn-info btn-large" style="border-radius: 5px">添加异动情况</button>
    <form action="/transaction/leadOut" method="post" style="display: inline-block;">
      <input id="cuId2" name="cuId" type="text" style="display: none" >
      <input type="submit" class="btn btn-info btn-large" style="border-radius: 5px"; value="全部导出";>
    </form>
    <div class="row-fluid">
      <div class="span12">
        <div class="widget-box">
          <div class="widget-title"> <span class="icon">
            </span>
            <h5>专业教师基本情况</h5>
          </div>
          <div class="widget-content nopadding">
            <span id="span1" style="color: red;" className="transaction"></span>
            <table id="t1" class="table table-bordered table-striped" frame="box">
              <thead>
              <tr >
                <th>编号</th>
                <th >教师姓名</th>
                <th >异动类型</th>
                <th >开始时间</th>
                <th >结束时间</th>
                <th >操作</th>
              </tr>
              </thead>
              <tbody id="tbody">

              </tbody>
            </table>

            <div class="pagination" style="margin-left: 70%">
              <ul>
                <li><a href="#" id="first">第一页</a></li>
                <li><a href="#" id="previous">上一页</a></li>
                <li><a href="#" pageNum="1">1</a> </li>
                <li><a href="#" pageNum="2">2</a></li>
                <li><a href="#" pageNum="3">3</a></li>
                <li><a href="#" pageNum="4">4</a></li>
                <li><a href="#" pageNum="5">5</a></li>
                <li><a href="#" id="next">下一页</a></li>
                <li><a href="#" id="last">最后一页</a></li>

                <li><a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <span id="span2"></span>&nbsp;&nbsp;共<span id="span3"></span>条记录
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</a></li>
              </ul>
            </div>
            <div id="form3" class="span12" style="display: none">
              <form id="form1" action="#" method="get" class="form-horizontal">
                <input id="cuId" name="cuId" type="text" style="display: none">
                <div class="control-group">
                  <label class="control-label">输入手机号以查询用户：</label>
                  <div class="controls">
                    <input id="tel" type="text" class="span11" />
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label">教师姓名 ：</label>
                  <div class="controls">
                    <input id="teacherName" name="teacherName" type="text" class="span11"  />
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label">异动类型：</label>
                  <div class="controls">
                    <select id="moveType"  name="moveType">
                      <option value="调出">调出</option>
                      <option value="退休">退休</option>
                      <option value="出国进修">出国进修</option>
                      <option value="病休产假">病休产假</option>
                    </select>
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label">开始时间：</label>
                  <div class="controls">
                    <input name="startTime" type="date" class="span11" />
                  </div>
                </div>
                <div class="control-group">
                  <label class="control-label">结束时间 ：</label>
                  <div class="controls">
                    <input name="endTime" type="date" class="span11"  />
                  </div>
                </div>
              </form>
              <center>
                <div class="control-group">
                  <div class="controls">
                    Excel：<input id="excel"  type="file" size="15" ><br>
                    <button id="leadIn" class="btn btn-primary btn-large" style="margin-bottom: 20px;border-radius: 5px">导入Excel</button>
                    <button id="btn1" class="btn btn-success btn-large" style="margin-bottom: 20px;border-radius: 5px">保存基本信息</button>
                  </div>
                </div>
              </center>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="http://www.jq22.com/jquery/jquery-1.7.1.js"></script>
<script src="../js/jquery.ui.custom.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootstrap-colorpicker.js"></script>
<script src="../js/bootstrap-datepicker.js"></script>

<script src="../js/masked.js"></script>
<script src="../js/jquery.uniform.js"></script>
<script src="../js/select2.min.js"></script>
<script src="../js/matrix.js"></script>
<script src="../js/matrix.form_common.js"></script>
<script src="../js/wysihtml5-0.3.0.js"></script>
<script src="../js/jquery.peity.min.js"></script>
<script src="../js/bootstrap-wysihtml5.js"></script>
<script type="text/javascript" src="../js/jquery.cookie.js"></script>
<script src="../js/tool.js"></script>

<script type="text/javascript">
  $(function () {
    var CLASS_NAME=$("#span1").attr("className");
    queryPage(1);
    $("#tel").live("blur",function inputOnBlur() {
      var tel=$(this).val();
      $.get("../users/findUserNameByTel/"+tel,{},function (result) {
          $("#teacherName").val(result.datas);
      },"json")
    })
    $("#su").click(function () {
      queryPage(1);
    })
    $(".pagination a").bind("click",function(){
      var num = $(this).attr("pageNum");
      if (num<=lastPage){
        queryPage(num);
      }
      if ($(".pagination a").attr("pageNum")==num){
        $(this).parent("li").attr("class","active");
      }
    });
    //保存
    $("#btn1").click(function () {
      var r = confirm("* 填报说明：\n" +
              "如有岗位异动情况，选择具体的异动类型进行填写，无岗位异动不用填写；\n" +
              "异动类型有调出、退休、出国进修、病休产假。其中为“调出”、“退休”的只填写“开始时间”，其他类型请根据实际情况填写；\n" +
              "同一情况的岗位异动可多次。\n" +
              "* 需提供资料：岗位异动证明\n\n" +
              "\t\t您是否确定保存？")
      if (r == true) {
        add(CLASS_NAME);
      } else {

      }
    })

  })
  //表格填充函数
  function queryPage(pageNum){
    var CLASS_NAME=$("#span1").attr("className");
    //当前页码
    pageNum= pageNum==undefined?1:pageNum;
    var name=$("#name").val();
    var moveType2=$("#moveType2").val();
    var startTime=$("#startTime").val();
    var endTime=$("#endTime").val();
    //页码的有效性判断
    $.get("../"+CLASS_NAME+"",{name:name,moveType:moveType2,startTime:startTime,endTime:endTime,page:pageNum,limit:5},function(result){
      console.log(result.data)
      //填充数据到tbody
      $("#tbody").empty();//清除之前的内容
      $(result.data).each(function(index,transaction){
        $("#tbody").append(
                " <tr>"+
                "<td>"+(index+1)+"</td>"+
                "<td>"+transaction.teacherName+"</td>"+
                "<td >"+transaction.moveType+"</td>"+
                "<td >"+transaction.startTime+"</td>"+
                "<td>"+transaction.endTime+"</td>"+
                "<td>"+
                "<a href='#' id='remove' class='icon-trash' eid="+transaction.id+" >删除</a></td>"+
                "</tr>"
        );
      })
      //给按钮添加对应的数值
      var num = pageNum;
      var count=result.count;
      lastPage=(count/5)%1===0?(count/5):parseInt(count/5)+1;
      $("a#first").attr("pageNum",1);
      $("a#previous").attr("pageNum",num-1<1?1:num-1);
      $("a#next").attr("pageNum",num+1>lastPage?lastPage:num+1);
      $("a#last").attr("pageNum",lastPage);
      $("span#span3").text(count);
      $("span#span2").text("第"+num+"页/共"+lastPage+"页");

      $("#pageNum").val(num);
    },"json");
  }
</script>
</body>
</html>
